package edu.njit.hz278.core.db;

import java.util.List;

/**
 * TODO CacheQuery is a cached wrapper of {@link Query}.
 * 
 * @author Rivers Zhang
 * 
 * @param <T>
 */
public class CachedQuery<T> implements IQuery<T> {

	protected final Query<T> query;

	public CachedQuery(Query<T> query) {
		this.query = query;
	}

	public T getByKeys(String[] keys, Object[] args) {
		return query.getByKeys(keys, args);
	}

	public T getByKey(String key, Object arg) {
		return query.getByKey(key, arg);
	}

	public List<T> getByKey(String key, Object[] args) {
		return query.getByKey(key, args);
	}

	public List<T> get(String[] fields, Object[] args, int page, int size) {
		return query.get(fields, args, page, size);
	}

	public List<T> get(String[] fields, Object[] args) {
		return query.get(fields, args);
	}

	public List<T> get(String field, Object arg, int page, int size) {
		return query.get(field, arg, page, size);
	}

	public List<T> get(String field, Object arg) {
		return query.get(field, arg);
	}

	public List<T> list() {
		return query.list();
	}

	public List<T> list(int page, int size) {
		return query.list();
	}

	public int insert(T object) {
		return query.insert(object);
	}

	public int update(T object, String[] whereAttrs) {
		return query.update(object, whereAttrs);
	}

	public int update(T object, String[] setAttr, String[] whereAttrs) {
		return query.update(object, setAttr, whereAttrs);
	}

	public int delete(T object, String[] whereAttrs) {
		return query.delete(object, whereAttrs);
	}

	public int delete(String[] attrs, Object[] args) {
		return query.delete(attrs, args);
	}

	@Override
	public List<T> getBySQL(String sql) {
		return query.getBySQL(sql);
	}

	@Override
	public List<T> getBySQL(String sql, Object... params) {
		return query.getBySQL(sql, params);
	}

	@Override
	public T getOneBySQL(String sql) {
		return query.getOneBySQL(sql);
	}

	@Override
	public T getOneBySQL(String sql, Object... params) {
		return query.getOneBySQL(sql, params);
	}

	@Override
	public int update(String sql) {
		return query.update(sql);
	}

	@Override
	public int update(String sql, Object... params) {
		return query.update(sql, params);
	}

	@Override
	public int delete(String attr, Object arg) {
		return query.delete(attr, arg);
	}

}
